import { managementService } from '~/config/server';
import { NetService } from '~/utils/net.service';
import { Inject, Debounce } from '~/core/decorator';

export class UserService {
  @Inject(NetService)
  private netService: NetService;

  /**
   * 增加用户
   */
  @Debounce()
  public createUser (data) {
    return this.netService.send({
      server: managementService.userController.createUser,
      data,
      loading: true,
    });
  }
  /**
   * 查询部门下的特定用户
   */
  @Debounce()
  public getAllUsers (data, page) {
    return this.netService.send({
      server: managementService.userController.getAllUsers,
      data,
      page,
    });
  }
  /**
   * 用户批量分配角色
   */
  @Debounce()
  public batchAllotRole (data) {
    return this.netService.send({
      server: managementService.userController.batchAllotRole,
      data,
      loading: true,
    });
  }
  /**
   * 修改用户
   */
  @Debounce()
  public modifyUser (data) {
    return this.netService.send({
      server: managementService.userController.modifyUser,
      data,
      loading: true,
    });
  }

  /**
   * 重置密码
   */
  @Debounce()
  public modifyUserPassword ({ userId }) {
    return this.netService.send({
      server: managementService.userController.modifyUserPassword,
      data: {
        userId,
      },
    });
  }

  /**
   * 批量设置催收员等级
   */
  @Debounce()
  public batchUpdateUserLevel (data) {
    return this.netService.send({
      server: managementService.userController.batchUpdateUserLevel,
      data,
    });
  }

  /**
   * 批量开启关闭分案
   */
  @Debounce()
  public batchCaseSwitch (data) {
    return this.netService.send({
      server: managementService.userController.batchCaseSwitch,
      data,
    });
  }

  /**
   * 根据查询所有用户不分页
   */
  public getAllUsersList (data) {
    return this.netService.send({
      server: managementService.userController.getAllUsersList,
      data,
    });
  }

  /**
   * 新增区域码
   */
  public addRegionalConfig (data) {
    return this.netService.send({
      server: managementService.userController.addRegionalConfig,
      data,
      loading: true,
    });
  }
  /**
   * 查询区域码列表
   */
  public getAllAreaConfigInfo (data, page) {
    return this.netService.send({
      server: managementService.userController.getAllAreaConfigInfo,
      data,
      page
    });
  }
  /**
   * 查询区域码详情
   */
  public getRegionalConfigById (data) {
    return this.netService.send({
      server: managementService.userController.getRegionalConfigById,
      data
    });
  }
  /**
   * 编辑区域码详情
   */
  public updateRegionalConfig (data) {
    return this.netService.send({
      server: managementService.userController.updateRegionalConfig,
      data,
      loading: true,
    });
  }

  /**
   * 列表-配置短信模板
   */
  public getAllSmsTemplateInfo (data, page, sort) {
    return this.netService.send({
      server: managementService.userController.getAllSmsTemplateInfo,
      data,
      page,
      sort
    });
  }

  /**
   * 创建-配置短信模板
   */
  public addSmsTemplateInfo (data) {
    return this.netService.send({
      server: managementService.userController.addSmsTemplateInfo,
      data,
      loading: true
    })
  }
  /**
   * 编辑-配置短信模板
   */
  public updateSmsTemplateInfo (data) {
    return this.netService.send({
      server: managementService.userController.updateSmsTemplateInfo,
      data
    })
  }
  /**
   * 外包机构管理
   */
  public getAllOutOrgInfo (data, page) {
    return this.netService.send({
      server: managementService.userController.getAllOutOrgInfo,
      data,
      page
    });
  }
  /**
   * 外包机构管理
   */
  public addOrgInfo (data) {
    return this.netService.send({
      server: managementService.userController.addOrgInfo,
      data,
      loading: true
    })
  }
  /**
   * 外包机构管理 - 查看
   */
  public getOrgInfoById (data) {
    return this.netService.send({
      server: managementService.userController.getOrgInfoById,
      data
    })
  }
  /**
   * 外包机构管理 - 编辑
   */
  public updateOrgInfo (data) {
    return this.netService.send({
      server: managementService.userController.updateOrgInfo,
      data,
      loading: true
    })
  }
  /**
   * 代码参数配置 - 新增
   */
  public addCodeConfigInfo (data) {
    return this.netService.send({
      server: managementService.userController.addCodeConfigInfo,
      data
    })
  }
  /**
   * 代码参数配置 - 获取列表
   */
  public getAllChildrenById (data) {
    return this.netService.send({
      server: managementService.userController.getAllChildrenById,
      data
    })
  }
  /**
   * 代码参数配置 - 删除
   */
  public deleteCodeConfigInfo (data) {
    return this.netService.send({
      server: managementService.userController.deleteCodeConfigInfo,
      data
    })
  }
  /**
   * 代码参数配置 - 修改
   */
  public updateCodeConfigInfo (data) {
    return this.netService.send({
      server: managementService.userController.updateCodeConfigInfo,
      data
    })
  }
  /**
   * 代码参数配置 - 关联修饰吗
   */
  public getChildrenById (data) {
    return this.netService.send({
      server: managementService.userController.getChildrenById,
      data
    })
  }
  /** 
   * 选择模板
   */
  public getAllSmsTemplate (data?) {
    return this.netService.send({
      server: managementService.userController.getAllSmsTemplate,
      data
    })
  }
  /** 
   * 模板预览
   */
  public getAllSmsTemplateById (data) {
    return this.netService.send({
      server: managementService.userController.getAllSmsTemplateById,
      data,
    })
  }

  public selectAllByCode (data) {
    return this.netService.send({
      server: managementService.userController.selectAllByCode,
      data
    })
  }

  public getSmsTemplate (data) {
    return this.netService.send({
      server: managementService.userController.getSmsTemplate,
      data
    })
  }

  public getSmsTemplateByNote (data) {
    return this.netService.send({
      server: managementService.userController.getSmsTemplateByNote,
      data
    })
  }
  public findAlreadyEffectCodeByType (data) {
    return this.netService.send({
      server: managementService.userController.findAlreadyEffectCodeByType,
      data
    })
  }

  public findRelationModifierCodeById (data) {
    return this.netService.send({
      server: managementService.userController.findRelationModifierCodeById,
      data
    })
  }
  public oneClickSmsTemplateSync () {
    return this.netService.send({
      server: managementService.userController.oneClickSmsTemplateSync
    })
  }
}
